package com.dc.wifi.main.ui.activity

import android.content.Intent
import android.widget.TextView
import com.dc.netlib.base.BaseActivity
import com.dc.netlib.extension.countDown
import com.dc.netlib.impl.NoMultiClickListener
import com.dc.wifi.R
import com.dc.wifi.databinding.ActivitySplashBinding
import com.dc.wifi.main.model.SplashViewModel
import com.dc.netlib.utils.LogUtil
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel

/**
 *Author: chinadragon
 *Time: 2024/5/20
 */
class SplashActivity : BaseActivity<SplashViewModel, ActivitySplashBinding>(R.layout.activity_splash,com.dc.wifi.BR.mSplashViewModel) {
    private var mCountDownJob: CoroutineScope? = null
    private lateinit var tvCountDown: TextView
    override fun initData() {
        super.initData()
        val second3 = 3
//        tvCountDown = binding.tvCountDown
//        this.countDown(time = second3, start = {
//            tvCountDown.setText("跳过 $second3 秒")
//            mCountDownJob = it
//        }, end = {
//            LogUtil.i("SplashActivity", "倒计时结束了")
//            //正式项目里需要判断用户是否已登录 TODO
            startActivity(Intent(this@SplashActivity, MainActivity::class.java))
//            finish()
//
//        }, next = {
//            LogUtil.i("SplashActivity", "剩余 $it 秒")
//            tvCountDown.setText("跳过 ${it - 1} 秒")
//
//        }, error = {
//
//        })
    }

    override fun initEvent() {
//        tvCountDown.setOnClickListener(NoMultiClickListener{
//            startActivity(Intent(this@SplashActivity, MainActivity::class.java))
//            finish()
//        })
    }

    override fun onDestroy() {
//        mCountDownJob?.let {
//            it.cancel()
//        }
        super.onDestroy()
    }
}